<template>
  <div class="index-page">
    <IndexPageHeader
      :font-size="20"
      style="height: 50px; margin-top: 20px"
      title="首页"
      icon="icon-sousuo"
      @topage="toSearchPage"
    />

    <!-- 活动参与 -->
    <div
      class="index-page-image"
      style="
        text-align: center;
        margin-top: 25px;
        height: 160px;
        overflow: hidden;
      "
    >
      <van-image fit="cover" width="100%" height="160px" :src="avatar" />
      <div class="index-page-image-filter"></div>
      <div class="index-page-image-tips">
        <h1>搞笑小猫咪</h1>
        <h2>萌宠搞笑瞬间大PK</h2>
        <button>立即参与</button>
      </div>
    </div>

    <!-- 分类区域 -->
    <div class="index-page-classes">
      <div
        class="index-page-classes-item"
        v-for="item in classTypes"
        :key="item.id"
      >
        <i :class="['iconfont', item.icon]"></i>
        <span>{{ item.name }}</span>
      </div>
    </div>

    <IndexPageHeader :font-size="18" title="育宠课堂" icon="icon-youjiantou" />
    <IndexPageHeader :font-size="18" title="热门文章" icon="icon-youjiantou" />
  </div>
</template>

<script lang="ts" setup>
import IndexPageHeader from "./components/index-page-header.vue";
import { Toast } from "vant";
import { onMounted } from "vue";
const avatar = require("../../assets/images/cat3.png");

const classTypes = [
  { id: "01", name: "签到", icon: "icon-yiqiandao" },
  { id: "02", name: "寄养", icon: "icon-home" },
  { id: "03", name: "领养", icon: "icon-cat" },
  { id: "04", name: "我的宠物", icon: "icon-chongwu" },
];

const toSearchPage = () => {
  Toast("搜索页面还在装修中");
};

onMounted(() => {
  console.log("代码执行测试");
});
</script>

<style lang="less" scoped>
.index-page {
  height: calc(100vh - 50px);
  overflow: auto;
  background-color: var(--background-color-std-1);
  padding: 0 20px;
  background-color: #fcfcfc;

  &-classes {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 0 2px;
    &-item {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      > span {
        font-size: 14px;
        margin-top: 12px;
        color: #333;
      }

      .iconfont {
        font-size: 18px;
        background-color: #e92322;
        color: #fff;
        // padding: 14px;
        height: 45px;
        width: 45px;
        display: flex;
        justify-content: center;
        align-items: center;
        border-radius: 50%;
      }
    }

    &-item:nth-of-type(1) {
      .iconfont {
        background-color: #ffd200;
      }
    }

    &-item:nth-of-type(2) {
      .iconfont {
        background-color: #ff4946;
      }
    }

    &-item:nth-of-type(3) {
      .iconfont {
        background-color: #22d59c;
        font-size: 22px;
      }
    }

    &-item:nth-of-type(4) {
      .iconfont {
        background-color: #409fea;
        font-size: 24px;
      }
    }
  }

  &-image {
    position: relative;

    &-filter {
      position: absolute;
      top: 0;
      right: 0;
      left: 0;
      bottom: 0;
      border-radius: 4px;
      background-color: rgba(0, 0, 0, 0.1);
    }

    &-tips {
      position: absolute;
      top: 0;
      bottom: 0;
      left: 20px;
      right: 0;
      color: #fff;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      justify-content: center;

      h1 {
        font-size: 20px;
        margin-bottom: 10px;
      }

      h2 {
        font-size: 16px;
        margin-bottom: 20px;
      }

      button {
        padding: 5px 12px;
        font-size: 12px;
        color: #fff;
        border: none;
        background-color: #22d59c;
        border-radius: 3px;
      }
    }
    ::v-deep .van-image__img {
      display: block;
      border-radius: 4px;
    }
  }
}
</style>
